#ifndef URL_H
#define URL_H 1

#include "main.h"
#include "array.h"
#include "string.h"
#include "hashmap.h"

#define URL_MAP_INITSIZ 5
#define MAX_URL_LEN 128
#define MAX_QRY_ARGS 10


typedef enum __ncattr__ url_type {
  URL_BUILTIN = 0,
  URL_STATIC = 1
} url_type_t;

typedef struct array url_object_arr_t;
typedef struct __ncattr__ url_object {
  string_t *uri;
  string_t *path;
  url_type_t type;
  void *data;
  void *__unused;
} url_object_t;

void
init_url_handler(void);

url_object_t *
url_register(const char *uri, const char *path, const url_type_t type, void *__data);

void
url_set_unused(url_object_t *obj, void *ptr);

void
url_free(void);

string_t *
url_parse_path(const char *doc_request);

url_object_t *
url_get(string_t *parsed_url);

map_t
url_parse_query(const char *query_str);

void
url_free_query(map_t *qry);

#endif
